﻿#ifndef DATATHREAD_H
#define DATATHREAD_H
#include "mymap.h"
#include <QObject>
#include <QThread>
#include <QDebug>
#include <QTimer>
#include <QReadWriteLock>
#include <QtEndian>
#include <QDateTime>
#include <QMetaType>
#include <QDir>
#include <QtXlsx>
#include "pb_common.h"
#include "pb_decode.h"
#include "pb_encode.h"
#include "traffic_info.pb.h"

#define TCP_RT_TARGET_CNT		512

#pragma pack(1)
typedef struct {
    u8_t id;
    float posX;
    float posY;
    float velX;
    float velY;
    float accX;
    float accY;
    u8_t laneNum;
    u8_t carType;
    char event;
    u8_t snowId[8];
    char reservedSpace3[4];
    u8_t Confidence;
    char reservedSpace4[3];
    float x1;
    u16_t tarNum;
    char carLen;
    char reservedSpace1;
    u16_t idHw;
    char reservedSpace2[4];
    float ath;
    double axis_longitude;
    double axis_latitude;
    char reservedSpace[1];
    u8_t RCS;
}TrjInfo;
#pragma pack()
#pragma pack(1)
typedef struct {
    unsigned char header[4];
    unsigned int length;
    u8_t time1[6];
    ULONGLONG time2;
    u8_t id[2];
    u8_t posBegin;
    u8_t queueLength[12];
    u16_t res1;
    u8_t res2;
    u16_t changeLanes;
    u16_t retrograde;
    u16_t stopCar;
    u16_t NOLINE;
    u16_t LINES;
    u16_t CLOSECAR;
    u16_t OUTTIME;
    u16_t HIGHPEED;
    u16_t LOWPEED;
    u16_t NUMBERS;
    u8_t reserved[18];
    u16_t numObject;
    TrjInfo trj[TCP_RT_TARGET_CNT];
}TrajactoryOutput;
#pragma pack()
class DataThread : public QThread
{
	Q_OBJECT
public:
    DataThread();
protected:
	void run() Q_DECL_OVERRIDE;
signals:
    void sendsize(unsigned long long);
    void sendprogress(float);
private:
    void analyserDate();
    QByteArray hexStrToByteArray(const QString &str);
    char convertHexChar(char ch);
};

#endif // MYTHREAD_H
